home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / DriverServices.p < prev    next >
Encoding:
Text File  |  1998-02-12  |  14.3 KB  |  458 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        DriverServices.p
  3.  
  4.      Contains:    Driver Services Interfaces.
  5.  
  6.      Version:    Technology:    PowerSurge 1.0.2
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT DriverServices;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __DRIVERSERVICES__}
  28. {$SETC __DRIVERSERVICES__ := 1}
  29.  
  30. {$I+}
  31. {$SETC DriverServicesIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __CONDITIONALMACROS__}
  35. {$I ConditionalMacros.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MACTYPES__}
  38. {$I MacTypes.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __ERRORS__}
  41. {$I Errors.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __MACHINEEXCEPTIONS__}
  44. {$I MachineExceptions.p}
  45. {$ENDC}
  46. {$IFC UNDEFINED __DEVICES__}
  47. {$I Devices.p}
  48. {$ENDC}
  49. {$IFC UNDEFINED __DRIVERSYNCHRONIZATION__}
  50. {$I DriverSynchronization.p}
  51. {$ENDC}
  52.  
  53.  
  54. {$PUSH}
  55. {$ALIGN POWER}
  56. {$LibExport+}
  57.  
  58. {*****************************************************************
  59.  *
  60.  *         Previously in Kernel.h
  61.  *
  62.  *****************************************************************}
  63. {  Kernel basics }
  64.  
  65. TYPE
  66.     IOPreparationID = ^LONGINT;
  67.     SoftwareInterruptID = ^LONGINT;
  68.     TaskID = ^LONGINT;
  69.     TimerID = ^LONGINT;
  70. {  OrderedItem stuff }
  71.     OrderedItemService                    = OSType;
  72.     OrderedItemSignature                = OSType;
  73.  
  74. CONST
  75.     kMatchAnyOrderedItemService    = '****';
  76.     kMatchAnyOrderedItemSignature = '****';
  77.     kDoNotMatchAnyOrderedItemService = '----';
  78.     kDoNotMatchAnyOrderedItemSignature = '----';
  79.  
  80.  
  81. TYPE
  82.     OrderedItemNamePtr = ^OrderedItemName;
  83.     OrderedItemName = RECORD
  84.         service:                OrderedItemService;
  85.         signature:                OrderedItemSignature;
  86.     END;
  87.  
  88.     OrderedItemOptions                    = OptionBits;
  89.  
  90. CONST
  91.     kOrderedItemIsRightBefore    = $00000001;
  92.     kOrderedItemIsRightAfter    = $00000002;
  93.  
  94.  
  95. TYPE
  96.     OrderRequirementsPtr = ^OrderRequirements;
  97.     OrderRequirements = RECORD
  98.         options:                OrderedItemOptions;
  99.         itemBefore:                OrderedItemName;
  100.         itemAfter:                OrderedItemName;
  101.     END;
  102.  
  103. {  Tasking }
  104.     ExecutionLevel                        = UInt32;
  105.  
  106. CONST
  107.     kTaskLevel                    = 0;
  108.     kSoftwareInterruptLevel        = 1;
  109.     kAcceptFunctionLevel        = 2;
  110.     kKernelLevel                = 3;
  111.     kSIHAcceptFunctionLevel        = 4;
  112.     kSecondaryInterruptLevel    = 5;
  113.     kHardwareInterruptLevel        = 6;
  114.  
  115.  
  116. TYPE
  117. {$IFC TYPED_FUNCTION_POINTERS}
  118.     SoftwareInterruptHandler = PROCEDURE(p1: UNIV Ptr; p2: UNIV Ptr); C;
  119. {$ELSEC}
  120.     SoftwareInterruptHandler = ProcPtr;
  121. {$ENDC}
  122.  
  123. {$IFC TYPED_FUNCTION_POINTERS}
  124.     SecondaryInterruptHandler2 = FUNCTION(p1: UNIV Ptr; p2: UNIV Ptr): OSStatus; C;
  125. {$ELSEC}
  126.     SecondaryInterruptHandler2 = ProcPtr;
  127. {$ENDC}
  128.  
  129.  
  130. CONST
  131.     kCurrentAddressSpaceID        = -1;
  132.  
  133.  
  134. {  Memory System basics }
  135.  
  136. TYPE
  137.     LogicalAddressRangePtr = ^LogicalAddressRange;
  138.     LogicalAddressRange = RECORD
  139.         address:                LogicalAddress;
  140.         count:                    ByteCount;
  141.     END;
  142.  
  143.     PhysicalAddressRangePtr = ^PhysicalAddressRange;
  144.     PhysicalAddressRange = RECORD
  145.         address:                PhysicalAddress;
  146.         count:                    ByteCount;
  147.     END;
  148.  
  149. {  For PrepareMemoryForIO and CheckpointIO }
  150.     IOPreparationOptions                = OptionBits;
  151.  
  152. CONST
  153.     kIOMultipleRanges            = $00000001;
  154.     kIOLogicalRanges            = $00000002;
  155.     kIOMinimalLogicalMapping    = $00000004;
  156.     kIOShareMappingTables        = $00000008;
  157.     kIOIsInput                    = $00000010;
  158.     kIOIsOutput                    = $00000020;
  159.     kIOCoherentDataPath            = $00000040;
  160.     kIOTransferIsLogical        = $00000080;
  161.     kIOClientIsUserMode            = $00000080;
  162.  
  163.  
  164. TYPE
  165.     IOPreparationState                    = OptionBits;
  166.  
  167. CONST
  168.     kIOStateDone                = $00000001;
  169.  
  170.     kInvalidPageAddress            = -1;
  171.  
  172.  
  173. TYPE
  174.     AddressRangePtr = ^AddressRange;
  175.     AddressRange = RECORD
  176.         base:                    Ptr;
  177.         length:                    ByteCount;
  178.     END;
  179.  
  180. {  C's treatment of arrays and array pointers is atypical }
  181.     LogicalMappingTable                    = ARRAY [0..0] OF LogicalAddress;
  182.     LogicalMappingTablePtr                = ^LogicalMappingTable;
  183.     PhysicalMappingTable                = ARRAY [0..0] OF PhysicalAddress;
  184.     PhysicalMappingTablePtr                = ^PhysicalMappingTable;
  185.     AddressRangeTable                    = ARRAY [0..0] OF AddressRange;
  186.     AddressRangeTablePtr                = ^AddressRangeTable;
  187.     MultipleAddressRangePtr = ^MultipleAddressRange;
  188.     MultipleAddressRange = RECORD
  189.         entryCount:                ItemCount;
  190.         rangeTable:                AddressRangeTablePtr;
  191.     END;
  192.  
  193. {
  194.    Separate C definition so that union has a name.  A future version of the interfacer
  195.    tool will allow a name (that gets thrown out in Pascal and Asm).
  196. }
  197.     IOPreparationTablePtr = ^IOPreparationTable;
  198.     IOPreparationTable = RECORD
  199.         options:                IOPreparationOptions;
  200.         state:                    IOPreparationState;
  201.         preparationID:            IOPreparationID;
  202.         addressSpace:            AddressSpaceID;
  203.         granularity:            ByteCount;
  204.         firstPrepared:            ByteCount;
  205.         lengthPrepared:            ByteCount;
  206.         mappingEntryCount:        ItemCount;
  207.         logicalMapping:            LogicalMappingTablePtr;
  208.         physicalMapping:        PhysicalMappingTablePtr;
  209.         CASE INTEGER OF
  210.         0: (
  211.             range:                AddressRange;
  212.             );
  213.         1: (
  214.             multipleRanges:        MultipleAddressRange;
  215.             );
  216.     END;
  217.  
  218.     IOCheckpointOptions                    = OptionBits;
  219.  
  220. CONST
  221.     kNextIOIsInput                = $00000001;
  222.     kNextIOIsOutput                = $00000002;
  223.     kMoreIOTransfers            = $00000004;
  224.  
  225. {  For SetProcessorCacheMode }
  226.  
  227.  
  228. TYPE
  229.     ProcessorCacheMode                    = UInt32;
  230.  
  231. CONST
  232.     kProcessorCacheModeDefault    = 0;
  233.     kProcessorCacheModeInhibited = 1;
  234.     kProcessorCacheModeWriteThrough = 2;
  235.     kProcessorCacheModeCopyBack    = 3;
  236.  
  237. {  For GetPageInformation }
  238.  
  239.     kPageInformationVersion        = 1;
  240.  
  241.  
  242. TYPE
  243.     PageStateInformation                = UInt32;
  244.  
  245. CONST
  246.     kPageIsProtected            = $00000001;
  247.     kPageIsProtectedPrivileged    = $00000002;
  248.     kPageIsModified                = $00000004;
  249.     kPageIsReferenced            = $00000008;
  250.     kPageIsLockedResident        = $00000010;
  251.     kPageIsInMemory                = $00000020;
  252.     kPageIsShared                = $00000040;
  253.     kPageIsWriteThroughCached    = $00000080;
  254.     kPageIsCopyBackCached        = $00000100;
  255.     kPageIsLocked                = $00000010;                    {  Deprecated }
  256.     kPageIsResident                = $00000020;                    {  Deprecated }
  257.  
  258.  
  259. TYPE
  260.     PageInformationPtr = ^PageInformation;
  261.     PageInformation = RECORD
  262.         area:                    AreaID;
  263.         count:                    ItemCount;
  264.         information:            ARRAY [0..0] OF PageStateInformation;
  265.     END;
  266.  
  267.  
  268. {  Tasks  }
  269. FUNCTION CurrentExecutionLevel: ExecutionLevel; C;
  270. FUNCTION CurrentTaskID: TaskID; C;
  271. FUNCTION DelayFor(delayDuration: Duration): OSStatus; C;
  272. FUNCTION InPrivilegedMode: BOOLEAN; C;
  273.  
  274. {  Software Interrupts  }
  275. FUNCTION CreateSoftwareInterrupt(handler: SoftwareInterruptHandler; task: TaskID; p1: UNIV Ptr; persistent: BOOLEAN; VAR theSoftwareInterrupt: SoftwareInterruptID): OSStatus; C;
  276.  
  277. FUNCTION SendSoftwareInterrupt(theSoftwareInterrupt: SoftwareInterruptID; p2: UNIV Ptr): OSStatus; C;
  278. FUNCTION DeleteSoftwareInterrupt(theSoftwareInterrupt: SoftwareInterruptID): OSStatus; C;
  279. {$IFC TARGET_OS_MAC }
  280. {  Secondary Interrupts  }
  281. FUNCTION CallSecondaryInterruptHandler2(theHandler: SecondaryInterruptHandler2; exceptionHandler: ExceptionHandler; p1: UNIV Ptr; p2: UNIV Ptr): OSStatus; C;
  282. FUNCTION QueueSecondaryInterruptHandler(theHandler: SecondaryInterruptHandler2; exceptionHandler: ExceptionHandler; p1: UNIV Ptr; p2: UNIV Ptr): OSStatus; C;
  283. {$ENDC}  {TARGET_OS_MAC}
  284.  
  285. {  Timers  }
  286. FUNCTION SetInterruptTimer({CONST}VAR expirationTime: AbsoluteTime; handler: SecondaryInterruptHandler2; p1: UNIV Ptr; VAR theTimer: TimerID): OSStatus; C;
  287. FUNCTION CancelTimer(theTimer: TimerID; VAR timeRemaining: AbsoluteTime): OSStatus; C;
  288.  
  289. {  I/O related Operations  }
  290. FUNCTION PrepareMemoryForIO(VAR theIOPreparationTable: IOPreparationTable): OSStatus; C;
  291. FUNCTION CheckpointIO(theIOPreparation: IOPreparationID; options: IOCheckpointOptions): OSStatus; C;
  292.  
  293. {  Memory Operations  }
  294. FUNCTION GetPageInformation(addressSpace: AddressSpaceID; base: ConstLogicalAddress; requestedPages: ItemCount; version: PBVersion; VAR thePageInfo: PageInformation): OSStatus; C;
  295. {  Processor Cache Related  }
  296. FUNCTION SetProcessorCacheMode(addressSpace: AddressSpaceID; base: ConstLogicalAddress; length: ByteCount; cacheMode: ProcessorCacheMode): OSStatus; C;
  297. {*****************************************************************
  298.  *
  299.  *         Was in DriverSupport.h or DriverServices.h
  300.  *
  301.  *****************************************************************}
  302.  
  303. TYPE
  304.     DeviceLogicalAddressPtr                = ^LogicalAddress;
  305.  
  306. CONST
  307.     durationMicrosecond            = -1;                            {  Microseconds are negative }
  308.     durationMillisecond            = 1;                            {  Milliseconds are positive }
  309.     durationSecond                = 1000;                            {  1000 * durationMillisecond }
  310.     durationMinute                = 60000;                        {  60 * durationSecond, }
  311.     durationHour                = 3600000;                        {  60 * durationMinute, }
  312.     durationDay                    = 86400000;                        {  24 * durationHour, }
  313.     durationNoWait                = 0;                            {  don't block }
  314.     durationForever                = $7FFFFFFF;                    {  no time limit }
  315.  
  316.     k8BitAccess                    = 0;                            {  access as 8 bit }
  317.     k16BitAccess                = 1;                            {  access as 16 bit }
  318.     k32BitAccess                = 2;                            {  access as 32 bit }
  319.  
  320.  
  321. TYPE
  322.     Nanoseconds                            = UnsignedWide;
  323.     NanosecondsPtr                         = ^Nanoseconds;
  324.  
  325. FUNCTION IOCommandIsComplete(theID: IOCommandID; theResult: OSErr): OSErr; C;
  326. FUNCTION GetIOCommandInfo(theID: IOCommandID; VAR theContents: IOCommandContents; VAR theCommand: IOCommandCode; VAR theKind: IOCommandKind): OSErr; C;
  327. PROCEDURE UpdateDeviceActivity(VAR deviceEntry: RegEntryID); C;
  328. PROCEDURE BlockCopy(srcPtr: UNIV Ptr; destPtr: UNIV Ptr; byteCount: Size); C;
  329. FUNCTION PoolAllocateResident(byteSize: ByteCount; clear: BOOLEAN): LogicalAddress; C;
  330. FUNCTION PoolDeallocate(address: LogicalAddress): OSStatus; C;
  331. FUNCTION GetLogicalPageSize: ByteCount; C;
  332. FUNCTION GetDataCacheLineSize: ByteCount; C;
  333. FUNCTION FlushProcessorCache(spaceID: AddressSpaceID; base: LogicalAddress; length: ByteCount): OSStatus; C;
  334. FUNCTION MemAllocatePhysicallyContiguous(byteSize: ByteCount; clear: BOOLEAN): LogicalAddress; C;
  335. FUNCTION MemDeallocatePhysicallyContiguous(address: LogicalAddress): OSStatus; C;
  336.  
  337. FUNCTION UpTime: AbsoluteTime; C;
  338. PROCEDURE GetTimeBaseInfo(VAR minAbsoluteTimeDelta: UInt32; VAR theAbsoluteTimeToNanosecondNumerator: UInt32; VAR theAbsoluteTimeToNanosecondDenominator: UInt32; VAR theProcessorToAbsoluteTimeNumerator: UInt32; VAR theProcessorToAbsoluteTimeDenominator: UInt32); C;
  339.  
  340. FUNCTION AbsoluteToNanoseconds(absoluteTime: AbsoluteTime): Nanoseconds; C;
  341. FUNCTION AbsoluteToDuration(absoluteTime: AbsoluteTime): Duration; C;
  342. FUNCTION NanosecondsToAbsolute(nanoseconds: Nanoseconds): AbsoluteTime; C;
  343. FUNCTION DurationToAbsolute(duration: Duration): AbsoluteTime; C;
  344. FUNCTION AddAbsoluteToAbsolute(absoluteTime1: AbsoluteTime; absoluteTime2: AbsoluteTime): AbsoluteTime; C;
  345. FUNCTION SubAbsoluteFromAbsolute(leftAbsoluteTime: AbsoluteTime; rightAbsoluteTime: AbsoluteTime): AbsoluteTime; C;
  346. FUNCTION AddNanosecondsToAbsolute(nanoseconds: Nanoseconds; absoluteTime: AbsoluteTime): AbsoluteTime; C;
  347. FUNCTION AddDurationToAbsolute(duration: Duration; absoluteTime: AbsoluteTime): AbsoluteTime; C;
  348. FUNCTION SubNanosecondsFromAbsolute(nanoseconds: Nanoseconds; absoluteTime: AbsoluteTime): AbsoluteTime; C;
  349. FUNCTION SubDurationFromAbsolute(duration: Duration; absoluteTime: AbsoluteTime): AbsoluteTime; C;
  350. FUNCTION AbsoluteDeltaToNanoseconds(leftAbsoluteTime: AbsoluteTime; rightAbsoluteTime: AbsoluteTime): Nanoseconds; C;
  351. FUNCTION AbsoluteDeltaToDuration(leftAbsoluteTime: AbsoluteTime; rightAbsoluteTime: AbsoluteTime): Duration; C;
  352. FUNCTION DurationToNanoseconds(theDuration: Duration): Nanoseconds; C;
  353. FUNCTION NanosecondsToDuration(theNanoseconds: Nanoseconds): Duration; C;
  354.  
  355. FUNCTION PBQueueInit(qHeader: QHdrPtr): OSErr; C;
  356. FUNCTION PBQueueCreate(VAR qHeader: QHdrPtr): OSErr; C;
  357. FUNCTION PBQueueDelete(qHeader: QHdrPtr): OSErr; C;
  358. PROCEDURE PBEnqueue(qElement: QElemPtr; qHeader: QHdrPtr); C;
  359. FUNCTION PBEnqueueLast(qElement: QElemPtr; qHeader: QHdrPtr): OSErr; C;
  360. FUNCTION PBDequeue(qElement: QElemPtr; qHeader: QHdrPtr): OSErr; C;
  361. FUNCTION PBDequeueFirst(qHeader: QHdrPtr; VAR theFirstqElem: QElemPtr): OSErr; C;
  362. FUNCTION PBDequeueLast(qHeader: QHdrPtr; VAR theLastqElem: QElemPtr): OSErr; C;
  363. FUNCTION DeviceProbe(theSrc: UNIV Ptr; theDest: UNIV Ptr; AccessType: UInt32): OSStatus; C;
  364. FUNCTION DelayForHardware(absoluteTime: AbsoluteTime): OSStatus; C;
  365.  
  366.  
  367. {*****************************************************************
  368.  *
  369.  *         Was in Interrupts.h 
  370.  *
  371.  *****************************************************************}
  372. {  Interrupt types  }
  373.  
  374. TYPE
  375.     InterruptSetID = ^LONGINT;
  376.     InterruptMemberNumber                = LONGINT;
  377.     InterruptSetMemberPtr = ^InterruptSetMember;
  378.     InterruptSetMember = RECORD
  379.         setID:                    InterruptSetID;
  380.         member:                    InterruptMemberNumber;
  381.     END;
  382.  
  383.  
  384. CONST
  385.     kISTChipInterruptSource        = 0;
  386.     kISTOutputDMAInterruptSource = 1;
  387.     kISTInputDMAInterruptSource    = 2;
  388.     kISTPropertyMemberCount        = 3;
  389.  
  390.  
  391. TYPE
  392.     ISTProperty                            = ARRAY [0..2] OF InterruptSetMember;
  393.     InterruptReturnValue                = LONGINT;
  394.  
  395. CONST
  396.     kFirstMemberNumber            = 1;
  397.     kIsrIsComplete                = 0;
  398.     kIsrIsNotComplete            = -1;
  399.     kMemberNumberParent            = -2;
  400.  
  401.  
  402. TYPE
  403.     InterruptSourceState                = BOOLEAN;
  404.  
  405. CONST
  406.     kSourceWasEnabled            = true;
  407.     kSourceWasDisabled            = false;
  408.  
  409.  
  410.  
  411. TYPE
  412. {$IFC TYPED_FUNCTION_POINTERS}
  413.     InterruptHandler = FUNCTION(ISTmember: InterruptSetMember; refCon: UNIV Ptr; theIntCount: UInt32): InterruptMemberNumber; C;
  414. {$ELSEC}
  415.     InterruptHandler = ProcPtr;
  416. {$ENDC}
  417.  
  418. {$IFC TYPED_FUNCTION_POINTERS}
  419.     InterruptEnabler = PROCEDURE(ISTmember: InterruptSetMember; refCon: UNIV Ptr); C;
  420. {$ELSEC}
  421.     InterruptEnabler = ProcPtr;
  422. {$ENDC}
  423.  
  424. {$IFC TYPED_FUNCTION_POINTERS}
  425.     InterruptDisabler = FUNCTION(ISTmember: InterruptSetMember; refCon: UNIV Ptr): ByteParameter; C;
  426. {$ELSEC}
  427.     InterruptDisabler = ProcPtr;
  428. {$ENDC}
  429.  
  430.  
  431. CONST
  432.     kReturnToParentWhenComplete    = $00000001;
  433.     kReturnToParentWhenNotComplete = $00000002;
  434.  
  435.  
  436. TYPE
  437.     InterruptSetOptions                    = OptionBits;
  438. {  Interrupt Services  }
  439. FUNCTION CreateInterruptSet(parentSet: InterruptSetID; parentMember: InterruptMemberNumber; setSize: InterruptMemberNumber; VAR setID: InterruptSetID; options: InterruptSetOptions): OSStatus; C;
  440.  
  441. FUNCTION InstallInterruptFunctions(setID: InterruptSetID; member: InterruptMemberNumber; refCon: UNIV Ptr; handlerFunction: InterruptHandler; enableFunction: InterruptEnabler; disableFunction: InterruptDisabler): OSStatus; C;
  442.  
  443. FUNCTION GetInterruptFunctions(setID: InterruptSetID; member: InterruptMemberNumber; VAR refCon: UNIV Ptr; VAR handlerFunction: InterruptHandler; VAR enableFunction: InterruptEnabler; VAR disableFunction: InterruptDisabler): OSStatus; C;
  444. FUNCTION ChangeInterruptSetOptions(setID: InterruptSetID; options: InterruptSetOptions): OSStatus; C;
  445. FUNCTION GetInterruptSetOptions(setID: InterruptSetID; VAR options: InterruptSetOptions): OSStatus; C;
  446.  
  447.  
  448. {$ALIGN RESET}
  449. {$POP}
  450.  
  451. {$SETC UsingIncludes := DriverServicesIncludes}
  452.  
  453. {$ENDC} {__DRIVERSERVICES__}
  454.  
  455. {$IFC NOT UsingIncludes}
  456.  END.
  457. {$ENDC}
  458.